/*
 * @Author: your name
 * @Date: 2020-05-07 18:52:51
 * @LastEditTime: 2020-05-09 10:09:40
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \pmclouds-web\src\pages\PersonnelFiles\tpl\uploadConfig.js
 */
import { vendorsDanger as danger, vendorsWarning as warning , vendorsSuccess as success} from './../../../utils/config.js';
function getUploadConfig(){
    const config = {
        name: 'file',
        action: '/personnel/importFromExcel',
        showUploadList: false,
        headers: {},
        data : (file)=>{
            console.log(file,this.props.form.getFormItemValue('pkEnterprise'), 2222)

            return {
                // file,
                pkEnterprise: this.state.pk
            }
        },
        onChange(info) {
            let _me = this;
            console.log(info)
    
            if (info.file.status === 'done') {
                if (info.file.response.resultCode === 'ok') {
                    _me.setState({
                        tableData : [..._me.state.tableData, ...info.file.response.data.result],
                        initData : {...initData, tableData: [..._me.state.tableData, ...info.file.response.data.result]}
                    }, ()=>{
                        console.log(_me.state.tableData, _me.state.initData);
                    })
                    success({ 'text': '导入成功！' });
                } else {
                    danger({ 'text': `${info.file.response.exMsg}！` });
                }
            } else if (info.file.status === 'error') {
                danger({ 'text': `${info.file.response.exMsg}！` });
            }
        },
    }
    return config
}
export{
    getUploadConfig
}